package com.bijiawang.user.repository;

import com.bijiawang.user.domin.Favorites;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface  FavoritesRepository extends JpaRepository<Favorites, Integer> {
    List<Favorites> findAll();
    //通过用户名查询该用户收藏的所有商品
    List<Favorites> findAllByUserName(String userName);

//    @Modifying
//    @Query("update favorites set userName=#{newUsername} where userName=#{oldUsername}")
//    public void updateUsername(String oldUsername,String newUsername);
        @Transactional
        public int deleteByGoodsId(int goodsId);
}
